Basic Shape

Basic shapes are simple geometric shapes that can be added to a project to represent physical objects.

Properties

Name Type Description
Model String Can select one of: Cube, Sphere, Cylinder, Cone or Pyramid
Width Number Gets/Sets the Width of the basic shape in metres
Length Number Gets/Sets the Length of the basic shape in metres
Height Number Gets/Sets the Height of the basic shape in metres
Color String New in V7.0. Gets/Sets the name of the color of the equipment
Visible Boolean New in V7.0. Gets/Sets the visibility of the equipment

 

Script example:

			var obj = GetComponentByNameAndType("BasicShape1", "Basic Shape");
			obj.Height = 2.0;
			obj.Width = 2.0;
			obj.Length = 2.0;
			obj.Color = "Sym3 Red"
		

Functions

void GoToPosition(x, y, z, xSpeed, ySpeed, zSpeed);

void GoToPosition(x, y, z, xSpeed, ySpeed, zSpeed, xAcc, xDec, yAcc, yDec, zAcc, zDec);

void GoToPosition(x, y, z, xSpeed, ySpeed, zSpeed,CallbackFunction);

void GoToPosition(x, y, z, xSpeed, ySpeed, zSpeed,CallbackFunction, xAcc, xDec, yAcc, yDec, zAcc, zDec);

void GoToPosition(x, y, z, xSpeed, ySpeed, zSpeed,CallbackFunction, CallbackInterval);

void GoToPosition(x, y, z, xSpeed, ySpeed, zSpeed,CallbackFunction, CallbackInterval, xAcc, xDec, yAcc, yDec, zAcc, zDec);

void GoToPosition(x, y, z, xSpeed, ySpeed, zSpeed,CallbackFunction, intOffsetArray);

void GoToPosition(x, y, z, xSpeed, ySpeed, zSpeed,CallbackFunction, intOffsetArray, xAcc, xDec, yAcc, yDec, zAcc, zDec);

 

This function moves the basic shape to the specified xyz coordinate, the specified xyz speeds,callbackfunction is called,CallbackInterval is interval time after callback function is called,intOffsetArray is the time callback function is called when equipment reaches its destinaiton,xyz Ac is the acceleration of specific coordinates and xyz Dec is the deceleration of specific coordinates. See Example 1 below.

Parameter Name Type Description
x Number The X coordinate of the target position
y Number The Y coordinate of the target position
z Number The Z coordinate of the target position
xSpeed Number The speed along the X axis
ySpeed Number The speed along the Y axis
zSpeed Number The speed along the Z axis
CallbackFunction Function Callback function will be called
CallbackInterval Number Interval in milliseconds when callback function is called
intOffsetArray Array Array of integer values in milliseconds. The callback function is called when equipment reaches any of those offset.
xAcc Number Acceleration of X axis
xDec Number Deceleration of X axis
yAcc Number Acceleration of Y axis
yDec Number Deceleration of Y axis
zAcc Number Acceleration of Z axis
zDec Number Deceleration of Z axis

Return value - NONE

array StopMovement();

This cancels the effect of any GoToPosition command and leaves the object in the current position.

Return value - NONE

array GetPosition();

This gives the current position of the equipment. See Example 3 below

Return value - An array of 3 double values [x,y,z].

void Rotate(direction, tilt, roll, dirSpeed, tiltSpeed, rollSpeed);

void Rotate(direction, tilt, roll, dirSpeed, tiltSpeed, rollSpeed, dirAcc, dirDec, tiltAcc, tiltDec, rollAcc, rollDec);

void Rotate(direction, tilt, roll, dirSpeed, tiltSpeed, rollSpeed,CallbackFunction);

void Rotate(direction, tilt, roll, dirSpeed, tiltSpeed, rollSpeed,CallbackFunction, dirAcc, dirDec, tiltAcc, tiltDec, rollAcc, rollDec);

 

This function rotates the basic shape to the specified direction, tilt and roll coordinate, the specified direction, tilt and roll speeds,callbackfunction is called,direction, tilt and roll Ac is the acceleration of specific rotation and direction, tilt and roll Dec is the deceleration of specific rotation. See Example 1 below.

Parameter Name Type Description
Direction Number The direction of the target position
Tilt Number The tilt of the target position
Roll Number The Roll of the target position
dirSpeed Number The speed of direction rotation
tiltSpeed Number The speed of tilt rotations
rollSpeed Number The speed of roll rotation
CallbackFunction Function Callback function will be called
dirAcc Number Acceleration of direction rotation
dirDec Number Deceleration of direction rotation
tiltAcc Number Acceleration of tilt rotation
tiltDec Number Deceleration of tilt rotation
rollAcc Number Acceleration of roll rotation
rollDec Number Deceleration of roll rotation

Return value - NONE

array StopRotation();

This cancels the effect of any Rotate command and leaves the object in the current rotation.

Return value - NONE

array GetRotation();

This gives the current rotation of the equipment. See Example 3 below

Return value - An array of 3 double values [dir,tilt,roll].

Events

OnArrivePosition

Invoked when the basic shape arrives at the location specified by GoToPosition.

Callback Signature

Void xxxxxxxxxxxxxxxxx(sender: object, x: float, y: float, z: float);

 

Parameter Name Type Description
sender Object The basic shape object that has arrived at position
x Number The x coordinate of the basic shape
y Number the y coordinate of the basic shape
z Number the z coordinate of the basic shape

OnCompleteRotation

Invoked when the basic shape completes rotation specified by Rotate.

Callback Signature

Void xxxxxxxxxxxxxxxxx(sender: object, dir: float, tilt: float, roll: float);

 

Parameter Name Type Description
sender Object The basic shape object that has completed rotation
dir Number The direction of the basic shape
tilt Number the tilt of the basic shape
roll Number the roll of the basic shape

Bindable properties (Operator)

Along with the default bindable properties are also;

Height: Sets the Height of the shape

Width: Sets the Width of the shape

Length: Sets the Length of the shape

Color: Sets the Color of the shape

 

 

Example 1

			function OnSimulationStart()
			{
			InitAnimation();
			StartAnimation();	
			}

			function InitAnimation()
			{
			//-- get basic shapes
			_basicShape1 = GetComponentByNameAndType("BasicShape1", "Basic Shape");
			_basicShape1.X = 0.0
			_basicShape1.Y = 0.0
	
			_basicShape2 = GetComponentByNameAndType("BasicShape2", "Basic Shape");
			_basicShape2.X = 2.0
			_basicShape2.Y = 0.0
	
			_basicShape3 = GetComponentByNameAndType("BasicShape3", "Basic Shape");
			_basicShape3.X = 4.0
			_basicShape3.Y = 0.0
	 
			_basicShape4 = GetComponentByNameAndType("BasicShape4", "Basic Shape");
			_basicShape4.X = 6.0
			_basicShape4.Y = 0.0
	 
			_basicShape5 = GetComponentByNameAndType("BasicShape5", "Basic Shape");
			_basicShape5.X = 8.0
			_basicShape5.Y = 0.0
	 
			_basicShape6 = GetComponentByNameAndType("BasicShape6", "Basic Shape");
			_basicShape6.X = 10.0
			_basicShape6.Y = 0.0
	 
			_basicShape7 = GetComponentByNameAndType("BasicShape7", "Basic Shape");
			_basicShape7.X = 12.0
			_basicShape7.Y = 0.0
	 
			_basicShape8 = GetComponentByNameAndType("BasicShape8", "Basic Shape");
			_basicShape8.X = 14.0
			_basicShape8.Y = 0.0
			}

			function StartAnimation()
			{
			SubscribeToEvent("OnArrivePosition", _basicShape7.Name, "Basic Shape", "OnArrivePosition_callbackFromEvent");
			Move();
			}

			function OnArrivePosition_callback( sender,  x,  y,  z)
			{
			LogDebug("-> OnArrivePosition_callback " + sender.Name + " Arrived x=" + x + " y=" + y + " z=" + z)
			}

			function OnArrivePosition_callbackFormEvent( sender,  x,  y,  z)
			{
			LogDebug("-> OnArrivePosition_callbackFormEvent " + sender.Name + " Arrived x=" + x + " y=" + y + " z=" + z)
			}

			function Move()
			{
			//-- Default
			_basicShape1.GoToPosition(0, 0, 5, 0, 0, 1);
	
			//-- Default with Acceleration deceleration
			_basicShape2.GoToPosition(2, 0, 5, 0, 0, 1, 0, 0, 0, 0, 0.5, 0.5); 
	
			//-- With callback
			_basicShape3.GoToPosition(4, 0, 5, 0, 0, 1, OnArrivePosition_callback);
	
			//-- With callback and Acceleration deceleration
			_basicShape4.GoToPosition(6, 0, 5, 0, 0, 1, OnArrivePosition_callback, 0, 0, 0, 0, 0.5, 0.5); 
	
			//-- with callback, interval
			_basicShape5.GoToPosition(8, 0, 5, 0, 0, 1, OnArrivePosition_callback, 500);
	
			//-- With callback ,interval and Acceleration deceleration
			_basicShape6.GoToPosition(10, 0, 5, 0, 0, 1, OnArrivePosition_callback, 500, 0, 0, 0, 0, 0.5, 0.5);
	
			//-- With callback, offset
			_basicShape7.GoToPosition(12, 0, 5, 0, 0, 1, OnArrivePosition_callback, [3000,2000,1000,500]);
	
			//-- With callback, offset and acceleration deceleration
			_basicShape8.GoToPosition(14, 0, 5, 0, 0, 1, OnArrivePosition_callback, [3000,2000,1000,500], 0, 0, 0, 0, 0.5, 0.5); 
		}

Example 2

			var _basicShape1;
			var goingUp = true;

			function OnSimulationStart()
			{
			InitAnimation();
			StartAnimation();
			}

			function InitAnimation()
			{
			//-- get basic shape1:
			_basicShape1 = GetComponentByNameAndType("BasicShape1", "Basic Shape");

			//-- subscribe to event 'OnArrivePosition'
			SubscribeToEvent("OnArrivePosition", "BasicShape1", "Basic Shape", "OnArrivePosition_callback");	
			}

			function StartAnimation()
			{
			goingUp = true;
			Move();
			}

			function StopAnimation()
			{
			_basicShape1.StopMovement();
			}

			function OnArrivePosition_callback()
			{
			LogDebug("OnArrivePosition_callback called")
			goingUp = !goingUp;
			Move();
			}

			function Move()
			{
			if(goingUp)
			_basicShape1.GoToPosition(0, 0, 0, 0, 0, 0.9); // ask to go down (on Z axis)
			else
			_basicShape1.GoToPosition(0, 0, 3, 0, 0, 0.9); // ask to go up (on Z axis)
		}

Example 3

			var shape = GetComponentByNameAndType("BasicShape1", "Basic Shape");

			function OnSimulationStart()
			{
			Position();
			}

			function Position()
			{
			// start animation
			shape.GoToPosition(7, 0, 0, 1, 0, 1, Noop, [1000, 800, 600, 400, 200]);
			}
			
			function Noop(sender, x, y, z)
			{
			// get the current position and log it
			var pos = shape.GetPosition()
			LogDebug("X: " + pos[0] + " Y: " + pos[1] + " Z: " + pos[2])
		}

Example 4

		
			function OnSimulationStart()
			{
			LogDebug("OnSimulationStart called");
			StartAnimation();
			}

			function OnSimulationStopping() 
			{
			LogDebug("OnSimulationStopping called");

			}

			function OnSimulationStop()
			{
			LogDebug("OnSimulationStop called");
			}

			var _basicShape1 = GetComponentByNameAndType("BasicShape1", "Basic Shape");
			var _basicShape2 = GetComponentByNameAndType("BasicShape2", "Basic Shape");
			var _basicShape3 = GetComponentByNameAndType("BasicShape3", "Basic Shape");
			var _basicShape4 = GetComponentByNameAndType("BasicShape4", "Basic Shape");


			function StartAnimation()
			{
			SubscribeToEvent("OnCompleteRotation",_basicShape1.Name,"Basic Shape", "OnCompleteRotation_callback");	
			SubscribeToEvent("OnCompleteRotation",_basicShape3.Name,"Basic Shape", "OnCompleteRotation_callback");	
			LogDebug("StartAnimation called")
			Move();
			}


			function OnCompleteRotation_callback( sender,  dir,  tilt,  roll)
			{	
			LogDebug("OnCompleteRotation_callback called name "+sender.Name+" dir="+dir+" tilt="+tilt+" roll="+roll)
			}

			function Move()
			{

			_basicShape1.Rotate(-90, 0, 0, 10, 0, 0);
			_basicShape2.Rotate(0, -90, 0, 0, 10, 0,OnCompleteRotation_callback);
			_basicShape3.Rotate(0, 0, 90, 0, 0, 10,5,5,5,5,5,5);

			_basicShape4.Rotate(90, 90, 90, 10, 10, 10,OnCompleteRotation_callback,5,5,5,5,5,5);

			}